package com.hr.hrto.service.impl;

import com.hr.hrto.service.SendMailService;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 黄瑞
 * @Date: 2022/09/04/23:11
 * @Description:
 * @version:1.0
 */
@Service
public class SendMailServiceImpl implements SendMailService {

    @Resource
    private JavaMailSender javaMailSender;
    //
    private String from = "你的邮箱";
    //
    private String to = "目标邮箱";
    //
    private String subject = "来自王德发黑店的登录验证";
    //
    private String context = "欢迎光临王德发的黑店，在这里，您将享受到最差的态度，最难吃的食物，和最慢的速度。" +"\n"+"您的验证码是";
    @Override
    public void sendMail(String phone , String code) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setText(context+"\n"+code+"\n"+"验证码30分钟内有效，请妥善保管");
        message.setFrom(from);
        message.setTo(phone);
        message.setSubject(subject);
        javaMailSender.send(message);
    }
}
